package cn.wolfcode.wolf2w.service.impl;

import cn.wolfcode.wolf2w.domain.Scenic;
import cn.wolfcode.wolf2w.repository.ScenicRepository;
import cn.wolfcode.wolf2w.service.IScenicService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;


@Service
public class ScenicServiceImpl implements IScenicService {

    @Autowired
    private ScenicRepository scenicRepository;

    @Override
    public void save(Scenic scenic) {
        scenic.setId(null);
        scenicRepository.save(scenic);
    }

    @Override
    public void update(Scenic scenic) {
        scenicRepository.save(scenic);
    }

    @Override
    public void delete(String id) {
        scenicRepository.deleteById(id);
    }

    @Override
    public Scenic get(String id) {
        return scenicRepository.findById(id).orElse(null);
    }

    @Override
    public List<Scenic> list() {
        return scenicRepository.findAll();
    }
    
}
